home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2525 < prev    next >
Encoding:
Text File  |  1996-08-06  |  803 b   |  41 lines

  1. Path: info.spt.net.cn!usenet
  2. From: txwang@public.sta.net.cn (Wang TianXing)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: copy ctor and derived classes
  5. Date: Wed, 17 Jan 1996 13:25:22 GMT
  6. Organization: Shanghai Post & Telecommunication
  7. Distribution: world
  8. Message-ID: <4dit1h$37h@info.sta.net.cn>
  9. References: <DL38zz.50K@Virginia.EDU>
  10. NNTP-Posting-Host: ts2-8.sta.net.cn
  11. X-Newsreader: Forte Free Agent 1.0.82
  12.  
  13. gcl8a@Virginia.EDU (Gregory Carl Lewin) wrote:
  14.  
  15. | class Base{
  16. |     int i;
  17. |     public:
  18. |         Base(const Base& b) : i(b.i) {}
  19. | }
  20.  
  21. | class Derived : public Base{
  22. |     int j;
  23. |     public:
  24. |         Derived(const Derived& d) : /*tedious i(d.i) */
  25. | j(d.j) {}
  26. | };
  27.  
  28. try this:
  29.  
  30. class Derived : public Base {
  31.     int j;
  32. public:
  33.     Derived(const Derived& d) : Base(d), j(d.j) {}
  34. };
  35.  
  36. ---
  37. Wang TianXing
  38. txwang@public.sta.net.cn
  39.  
  40.  
  41.